<?php
$db_team = pc_base::load_model('team_model');
$db_people = pc_base::load_model('people_model');

$_order = (int) $_GET['order'];
$_classtype =(int) $_GET['classtype'];

$_orderArr = [
	0 => '默认',
	1 => '综合排序',//最热
	2 => '人气排序',
	3 => '开课时间排序',
];

$_classtypeArr = getcache(3360, 'linkage');
$_classtypeArr = $_classtypeArr['data'];

$sql = "select * from phpcms_classmany where status=99 and catid=1";
	if($_classtype){
	$sql .= " and classtype=$_classtype";
}
// TODO set order
switch ($_order) {
	case 1:
		$sql .= ' order by listorder desc,id desc';
		break;
	case 2:
		$sql .= ' order by num_view desc,id desc';
		break;
	case 3:
		$sql .= ' order by class_time1 desc,id desc';
		break;
	default:
		$sql .= ' order by listorder desc,id desc';
		break;
}
?>
{template "content","header"}

{template "content","header_nav_back_top"}

<div class="h_48"></div>
<!-- main -->
<main class="main">
	<ul class="navList1 clearfix">
		<li>
			<div class="nice-select">
				<input type="text" readonly="true" value="{if $_order!=0}{$_orderArr[$_order]}{else}综合排序{/if}" class="input1 j_down">
				<ul class="ul1">
					<li class="j_select{if $_order==0} on{/if}" data-type='order' data-value="0">默认排序</li>
					<li class="j_select{if $_order==2} on{/if}" data-type='order' data-value="2">人气排序</li>
					<li class="j_select{if $_order==3} on{/if}" data-type='order' data-value="3">开课时间排序</li>
				</ul>
			</div>
		</li>
		<li>
			<div class="nice-select">
				<input type="text" readonly="true" value="{if $_classtype!=0}{$_classtypeArr[$_classtype]['name']}{else}课程分类{/if}" class="input2 j_down">
				<ul class="ul1">
					<li class="j_select{if $_classtype==0} on{/if}" data-type='classtype' data-value="0">全部</li>
{loop $_classtypeArr $r}
					<li class="j_select{if $_classtype==$r[linkageid]} on{/if}" data-type='classtype' data-value="{$r[linkageid]}">{$r[name]}</li>
{/loop}
				</ul>
			</div>
		</li>
		<li class="hot"><a href="javascript:void(0);"><!-- <i></i> -->报名中</a></li>
	</ul>
	<ul class="oListclass">
{pc:get sql="$sql"}
{loop $data $c_one}
{php $team=$db_team->pkhs($c_one[one_team])}
{php $teacher=$db_people->pkhs($c_one[one_teacher])}
		<li>
			<a href="{$c_one[url]}">
				<div class="oListclasstime">
					<span class="time1 fl">{date('Y-m-d',$c_one[class_time1])}</span>
					<span class="peo fr">{$c_one[num_view]}</span>
				</div>
				<div class="oListclasscon clearfix">
					<div class="pic1 fl"><img src="{$c_one[thumb]}"><em>席位：{$c_one[student_limit]}</em></div>
					<div class="oListclasscon_rg">
						<div class="oListclasscon_rg_t">{$c_one[title]}</div>
						<div class="oListclasscon_rg_name">{$team[title]}<i class="icon_v"></i></div>
						<div class="oListclasscon_rg_teacher clearfix">
							<span class="fl">讲师：{$teacher[title]}</span>
							<div class="oListclasscon_rg_teacher_price fr"><em>{price2cn($c_one[price_base])}</em>
								{if $c_one[price_cut]}
									<i>￥{price2cn($c_one[price_cut])}</i>
								{else}
									<i class="free">免费</i>
								{/if}
							</div>
						</div>
					</div>
				</div>
			</a>
		</li>
{/loop}
{/pc}
	</ul>
	<!-- <div id="loading"></div>  -->
</main>
<!-- / main -->
<div class="h_48"></div>

<style type="text/css">
.nice-select input.j_down.on{background:#fff url({IMG_PATH2}icon/down2.png) no-repeat 100% 50%;background-size:8px;color:#32acdf;}
</style>
<script type="text/javascript">
var GET_PATH = '{GET_PATH}';
$(function(){
	//下拉选择
	var width1 = $(window).width();
	var height1 = $(window).height();
	$(".ul1").css({
		height: height1 + "px",
		width: '100%',
		background: "url({IMG_PATH2}icon/bg40.png) repeat"
	});
	$('.j_down').click(function(){
		$('.j_down').removeClass('on').next().hide();
		$(this).addClass('on').next().show();
	});
	$('.ul1').click(function(){
		$('.j_down').removeClass('on').next().hide();
	});
	$('.j_select').click(function(e){
		e.stopPropagation();
		var _this = $(this);
		var url = GET_PATH + '&' + _this.data('type')  + '=' + _this.data('value');
		location.href = url;
	});
});
</script>

{template "content","footer_nav"}

{template "content","footer"}